package com.qk.management.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qk.common.PageResult;
import com.qk.domain.log.OperatrLogDO;
import com.qk.dto.log.OperateLogDTO;
import com.qk.entity.OperateLog;
import com.qk.management.mapper.OperateLogMapper;
import com.qk.management.service.OperateLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
@SuppressWarnings("all")
public class OperateLogServiceImpl extends ServiceImpl<OperateLogMapper, OperateLog> implements OperateLogService {
    
    @Autowired
    private OperateLogMapper operateLogMapper;
    
    @Override
    public PageResult<OperatrLogDO> list(OperateLogDTO dto) {
        // 计算偏移量
        Integer offset = (dto.getPage() - 1) * dto.getPageSize();
        
        // 查询列表
        List<OperatrLogDO> logList = operateLogMapper.selectOperateLogList(dto, offset, dto.getPageSize());
        
        // 查询总数
        Integer total = operateLogMapper.selectOperateLogCount(dto);
        
        // 构造返回结果
        return PageResult.<OperatrLogDO>builder()
                .total(total)
                .rows(logList)
                .build();
    }
}